package gupao_edu_spring_aop.aop.framework.adapter;

import gupao_edu_spring_aop.aopalliance.intercept.MYJoinPoint;
import gupao_edu_spring_aop.aopalliance.intercept.MYMethodInterceptor;
import gupao_edu_spring_aop.aopalliance.intercept.MYReflectiveMethodInvocation;

import java.lang.reflect.Method;

/**
 * @ClassName:
 * @Description:
 * @Auther: zhouych
 * @Date: 2019/5/10 14:27
 */
public class MYMethodBeforeAdviceInterceptor extends MYAbstractAspectAdvice implements MYMethodInterceptor {


    private MYJoinPoint joinPoint;

    public MYMethodBeforeAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    private void before(Method method,Object[] args,Object target) throws Throwable{
        super.invokeAdviceMethod(this.joinPoint,null,null);

    }
    @Override
    public Object invoke(MYReflectiveMethodInvocation mi) throws Throwable {
        this.joinPoint = mi;
        before(mi.getMethod(), mi.getArguments(), mi.getThis());
        return mi.proceed();
    }
}
